//
//  WeakProxy.m
//  nstimer循环引用
//
//  Created by keisun on 2018/11/1.
//  Copyright © 2018年 keisun. All rights reserved.
//

#import "WeakProxy.h"
#import <objc/runtime.h>
@implementation WeakProxy

//以下三个方法必须的
- (instancetype)initWithTarget:(id)target {
    _target = target;
    return self;
}

+ (instancetype)proxyWithTarget:(id)target {
    return [[WeakProxy alloc] initWithTarget:target];
}

- (id)forwardingTargetForSelector:(SEL)selector {
    return _target;
}

//视图或控制器运用时在其dealloc方法中有[self.timer invalidate]，则可不必提供，不重写以下两个方法
- (NSMethodSignature *)methodSignatureForSelector:(SEL)selector {
    return [NSObject instanceMethodSignatureForSelector:@selector(init)];
}

- (void)forwardInvocation:(NSInvocation *)invocation {
    void *null = NULL;
    [invocation setReturnValue:&null];
}
@end
